<h4></h4>
<form action="">
	{{csrf_field()}}
	<div class="row" style="padding-bottom: 15px;margin-top: 0px;">
		<p class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="width: 70px; height: 32px;padding: 0px;text-align: right;line-height: 32px;">代理商：</p>
		<select name="ag" class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="height: 30px; line-height: 30px; padding: 0px; border: 1px solid #DDD; margin: 0px 10px; width: 10%;">
			<option value="">请选择代理商</option>
			@if(!null == $agent)
				@foreach($agent as $v)
					<option value="{{$v['id']}}"
							@if($get['ag'] == $v['id'])
							selected
							@else
							@if(Cookie::get('agentId') == $v['id'])
							selected
							@endif
							@endif>{!! $v['agent_name'] !!}</option>
				@endforeach
			@endif
		</select>
		<p class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="width: 70px; height: 32px;padding: 0px;text-align: right;line-height: 32px;">DevEUI：</p>
		<input type="text" name="eui" value="{{$get['eui']}}" class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="height: 30px; line-height: 30px; padding: 0px; border: 1px solid #DDD; margin: 0px 10px; width: 10%;"/>
		<p class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="width: 70px; height: 32px;padding: 0px;text-align: right;line-height: 32px;">区域：</p>
		<input type="text" name="area" value="{{$get['area']}}" class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="height: 30px; line-height: 30px; padding: 0px; border: 1px solid #DDD; margin: 0px 10px; width: 10%;"/>
		<p class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="width: 70px; height: 32px;padding: 0px;text-align: right;line-height: 32px;">建筑：</p>
		<input type="text" name="building" id="" value="{{$get['building']}}" class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="height: 30px; line-height: 30px; padding: 0px; border: 1px solid #DDD; margin: 0px 10px; width: 10%;"/>
		<p class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="width: 70px; height: 32px;padding: 0px;text-align: right;line-height: 32px;">房间：</p>
		<input type="text" name="room" id="" value="{{$get['room']}}" class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="height: 30px; line-height: 30px; padding: 0px; border: 1px solid #DDD; margin: 0px 10px; width: 10%;"/>
		<input type="button" value="搜索" onclick="fun('submit','{{ $get['apply'] }}')" class="col-lg-1 col-md-1 col-sm-1 col-xs-1"  style="height: 30px; line-height: 32px; padding: 0px; border: 0; background: #4F52BA;width: 50px; margin: 0px 10px;color:#fff"/>
	</div>
</form>
<table class="table table-bordered" style="text-align: center">
	<thead>
	<tr>
		<th style="text-align: center">编号</th>
		<th style="text-align: center">DevEUI</th>
		<th style="text-align: center">类型</th>
		<th style="text-align: center">型号</th>
		<th style="text-align: center">区域</th>
		<th style="text-align: center">建筑</th>
		<th style="text-align: center">房间</th>
		<th style="text-align: center">全体负责人</th>
		<th style="text-align: center">具体位置</th>
		<th style="text-align: center">绑定时间</th>
		@if($get['ag'] == Cookie::get('agentId') || Cookie::get('agentId') == 1)
			<th style="text-align: center">操作</th>
		@endif
		<th style="text-align: center">通知</th>
	</tr>
	</thead>
	<tbody>
	@if($info != null)
		@foreach($info as $v)
			<tr>
				<th scope="row" style="text-align: center">{{$v['num']}}</th>
				<td>{{$v['eui']}}</td>
				<td>{{$v['type']}}</td>
				<td>{{$v['t_model']}}</td>
				<td><a href="/admin/area/index?ag=@if($get['ag']){{$get['ag']}}@else{{$v['agent_id']}}@endif&area={{$v['a_name']}}">{{$v['a_name']}}</a></td>
				<td><a href="/admin/building/index?ag=@if($get['ag']){{$get['ag']}}@else{{$v['agent_id']}}@endif&area={{$v['a_name']}}&building={{$v['b_name']}}">{{$v['b_name']}}</a></td>
				<td><a href="/admin/room/index?ag=@if($get['ag']){{$get['ag']}}@else{{$v['agent_id']}}@endif&area={{$v['a_name']}}&building={{$v['b_name']}}&room={{$v['r_name']}}">{{$v['r_name']}}</a></td>
				<td>
					@if($v['a_user_str']!= '')
						区域 : {{$v['a_user_str']}}
					@endif
					@if($v['b_user_str'] != '')
						建筑 : {{$v['b_user_str']}}
					@endif
					@if($v['r_user_str'] != '')
						房间 : {{$v['r_user_str']}}
					@endif
				</td>
				<td>{{$v['location']}}</td>
				<td>{{$v['add_time']}}</td>
				@if($get['ag'] == Cookie::get('agentId') || Cookie::get('agentId') == 1)
					<td><a href="/admin/device/edit?ag={{$get['ag']}}&id={{$v['id']}}&app={{ $get['apply'] }}">编辑</a>&nbsp;|&nbsp;<a href="javascript:void (0)" onclick=del({{$v['id']}},"{{ $get['apply'] }}")>删除</a></td>
				@endif
				<td>
					<div style="width: 40px;cursor:pointer;height: 22px;border-radius:20px;background: #bdbdbd;">
			            <input type="checkbox" name="status" id="male"
			            apply="{{$get['apply']}}" eid="{{$v['id']}}" value="{{$v['status']}}" class="chooseBtn" />
	                    <label for="male" class="choose-label"></label>
	                </div>
	            </td>
			</tr>
		@endforeach
	@endif
	</tbody>
</table>
<script type="text/javascript">
	$(".choose-label").each(function(e){
		// 判断通知状态,改变样式
		if($('input[name=status]:eq('+e+')').val()==1){
			$(this).css("left","9px");
			$(this).parent().css("background","#51ccee");
		}else{
			$(this).css("left","-9px");
			$(this).parent().css("background","#bdbdbd");
		}
		// 点击事件
		$(this).click(function(){
			tostatus(e);
			return false;
		});
		$(this).parent().click(function(){
			tostatus(e);
			return false;
		});
	});
	
	function tostatus(e){
		// 获取相关参数
		var status = $('input[name=status]:eq('+e+')').val();
		var apply = $('input[name=status]:eq('+e+')').attr('apply');
		var id = $('input[name=status]:eq('+e+')').attr('eid');
		$.ajax(
		{
			type:"post",
			url:"/admin/device/status",
			async:false,
			data:{
				"_token": $('input[name=_token]').val(),
				"rd_status":status,
				"apply":apply,
				"id":id
			},
			dataType:"html",
			success:function(jstr)
			{
				if(jstr==1){
					// 更改标志符
					$('input[name=status]:eq('+e+')').val("1");
					// 更改样式
					$(".choose-label").eq(e).css("left","9px");
					$(".choose-label").eq(e).parent().css("background","#51ccee");
				}else{
					// 更改标志符
					$('input[name=status]:eq('+e+')').val("0");
					// 更改样式
					$(".choose-label").eq(e).css("left","-9px");
					$(".choose-label").eq(e).parent().css("background","#bdbdbd");
				}
			}
		});
	}
</script>
<nav class="lw_page" style="float: right;">
	@if($arr['lastItem']&&$arr['lastItem']!=1)
		<ul class="pagination">
			<li @if($arr['current']==1) class="disabled" @else style="cursor:pointer" @endif>
				<a aria-label="Previous" onclick="fun('1','{{ $get['apply'] }}')" num="1">
					<span aria-hidden="true">«</span>
				</a>
			</li>
			@if($arr['lastItem']<=10)
				@for($i=1;$i<=$arr['lastItem'];$i++)
					<li @if($arr['current']==$i) class="active" @endif>
						<a style="cursor:pointer" onclick="fun('{{$i}}','{{ $get['apply'] }}')" num="{{$i}}">{{$i}}</a>
					</li>
				@endfor
			@else
				@if($arr['current']<7)
					@for($i=1;$i<=8;$i++)
						<li style="cursor:pointer" @if($arr['current']==$i) class="active" @endif>
							<a onclick="fun('{{$i}}','{{ $get['apply'] }}')" num="{{$i}}">{{$i}}</a>
						</li>
					@endfor
					<li  class="disabled">
						<a>...</a>
					</li>
					<li style="cursor:pointer">
						<a onclick="fun('{{ $arr['lastItem']-1 }}','{{ $get['apply'] }}')" num="{{ $arr['lastItem']-1 }}">{{ $arr['lastItem']-1 }}</a>
					</li>
					<li style="cursor:pointer">
						<a onclick="fun('{{ $arr['lastItem'] }}','{{ $get['apply'] }}')" num="{{ $arr['lastItem'] }}">{{ $arr['lastItem'] }}</a>
					</li>
				@else
					@if(($arr['current']>$arr['lastItem']-6))
						<li style="cursor:pointer">
							<a onclick="fun('1','{{ $get['apply'] }}')" num="1"> 1 </a>
						</li>
						<li style="cursor:pointer">
							<a onclick="fun('2','{{ $get['apply'] }}')" num="2"> 2 </a>
						</li>
						<li  class="disabled">
							<a>...</a>
						</li>
						@for($i=$arr['lastItem']-7;$i<=$arr['lastItem'];$i++)
							<li @if($arr['current']==$i) class="active" @endif>
								<a style="cursor:pointer" onclick="fun('{{$i}}','{{ $get['apply'] }}')" num="{{$i}}">{{$i}}</a>
							</li>
						@endfor
					@else
						<li style="cursor:pointer">
							<a onclick="fun('1','{{ $get['apply'] }}')" num="1"> 1 </a>
						</li>
						<li style="cursor:pointer">
							<a onclick="fun('2','{{ $get['apply'] }}')" num="2"> 2 </a>
						</li>
						<li  class="disabled">
							<a>...</a>
						</li>
						@for($i=$arr['current']-2;$i<=$arr['current']+2;$i++)
							<li @if($arr['current']==$i) class="active" @endif>
								<a style="cursor:pointer" onclick="fun('{{$i}}','{{ $get['apply'] }}')" num="{{$i}}">{{$i}}</a>
							</li>
						@endfor
						<li  class="disabled">
							<a>...</a>
						</li>
						<li style="cursor:pointer">
							<a onclick="fun('{{ $arr['lastItem']-1 }}','{{ $get['apply'] }}')" num="{{ $arr['lastItem']-1 }}">{{ $arr['lastItem']-1 }}</a>
						</li>
						<li style="cursor:pointer">
							<a onclick="fun('{{ $arr['lastItem'] }}','{{ $get['apply'] }}')" num="{{ $arr['lastItem'] }}">{{ $arr['lastItem'] }}</a>
						</li>
					@endif
				@endif
			@endif
			<li @if($arr['current']==$arr['lastItem'])class="disabled" @else style="cursor:pointer" @endif>
				<a aria-label="Next" onclick="fun({{ $arr['lastItem'] }},'{{ $get['apply'] }}')" num="{{$arr['lastItem']}}">
					<span aria-hidden="true">»</span>
				</a>
			</li>
		</ul>
	@endif
</nav>